﻿using Dln.Common;
using Dln.Handler;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Dln.Handler
{
    public class MenuHelper
    {
        /// <summary>
        /// 菜单文件路径
        /// </summary>
        private static readonly string Menu_Data_Path = System.AppDomain.CurrentDomain.BaseDirectory + "/Data/menu.txt";
        /// <summary>
        /// 获取菜单
        /// </summary>
        public static string GetMenu()
        {
            string url = string.Format("https://api.weixin.qq.com/cgi-bin/menu/get?access_token={0}", TokenBussiness.GetTokenKey());

            return RequestHelper.SendGet(url);
        }
        /// <summary>
        /// 创建菜单
        /// </summary>
        public static string CreateMenuS()
        {
            //http://218.93.252.183:8090/\
            //http://www.healthyperson.cn/Page/Community/UserInfo.aspx\
            string link = SecurityHelper.SetMD5(WeiXinConfig.MainUrl + "/page/member/MemberCenter.aspx");
            string url = string.Format("https://api.weixin.qq.com/cgi-bin/menu/create?access_token={0}", TokenBussiness.GetTokenKey());
            string menu = "{" +
            "\"button\": [" + "{" +
                            "\"name\": \"走进医院\", " +
                                "\"sub_button\": [" +
                                    "{" +
                                        "\"type\": \"view\", " +
                                        "\"name\": \"微官网\", " +
                                        "\"url\": \"http://www.hadln.cn/Page/Weixin/Index.aspx\"" +
                                    "}," +
                                    "{" +
                                        "\"type\": \"view\", " +
                                        "\"name\": \"健康教育\", " +
                                        "\"url\": \"http://www.hadln.cn/Page/Weixin/Healthy.aspx\"" +
                                    "}," +
                                    "{" +
                                        "\"type\": \"view\", " +
                                        "\"name\": \"报修平台\", " +
                                        "\"url\": \"http://www.hadln.cn/Page/AutoRun/Contact.aspx\"" +
                                    "}" +

                               " ]" +
                            "}," +
                            "{" +
                            "\"name\": \"就医服务\", " +
                                "\"sub_button\": [" +
                                    "{" +
                                        "\"type\": \"view\", " +
                                        "\"name\": \"门诊预约\", " +
                                        "\"url\": \"http://www.hadln.cn/Message.aspx\"" +
                                    "}," +
                                    "{" +
                                        "\"type\": \"view\", " +
                                        "\"name\": \"编辑就诊人\", " +
                                        "\"url\": \"http://www.hadln.cn/Page/Customer/AllPatient.aspx\"" +
                                    "},"+
                                    "{" +
                                        "\"type\": \"view\", " +
                                        "\"name\": \"查看报告\", " +
                                        "\"url\": \"http://www.hadln.cn/Page/Customer/ReportSelectPerson.aspx\"" +
                                    "}," +
                                    "{" +
                                        "\"type\": \"view\", " +
                                        "\"name\": \"我的预约\", " +
                                        "\"url\": \"http://www.hadln.cn/Message.aspx\"" +
                                    "}" +
                               " ]" +
                            "}," +
                            "{" +
                            "\"name\": \"自助缴费\", " +
                                "\"sub_button\": [" +
                                    "{" +
                                        "\"type\": \"view\", " +
                                        "\"name\": \"门诊缴费\", " +
                                        "\"url\": \"http://www.hadln.cn/Page/Customer/MoneySelectPerson.aspx\"" +
                                    "}," +
                                    "{" +
                                        "\"type\": \"view\", " +
                                        "\"name\": \"住院缴费\", " +
                                        "\"url\": \"http://www.hadln.cn/Message.aspx\"" +
                                    "}," +
                                    "{" +
                                        "\"type\": \"view\", " +
                                        "\"name\": \"我的缴费历史\", " +
                                        "\"url\": \"http://www.hadln.cn/Page/Customer/PayOrdHistory.aspx\"" +
                                    "}" +
                               " ]" +
                            "}" +
                        "]" +
                          "}";
            return RequestHelper.SendPost(url, menu);
        }
    }
}
